%% case222

tic
pathnum=10000;
intBMsq=zeros(51,1);
time=linspace(0,1/2,51)';
for pn=1:pathnum
    disp(pn);
    getpath=randommc(5001,222);
    %getpath=ones(size(getpath));
    %BMsq=getpath;   
    BMsq=getpath.^2; 
    for jj=1:51
        intBMsq(jj)=intBMsq(jj)+midptrule(BMsq(1:(jj-1)*100+1),1/10000)^2;
        %intBMsq(jj)=intBMsq(jj)+BMsq((jj-1)*100+1);
    end
end

mcpart=intBMsq/pathnum;
fname='case222';
save(fname,'mcpart');
toc

%% case221

tic
pathnum=50000;
intBMsq=zeros(51,1);
time=linspace(0,1/2,51)';
for pn=1:pathnum
    disp(pn);
    getpath=randommc(5001,221);
    %getpath=ones(size(getpath));
    %BMsq=getpath;   
    BMsq=getpath.^2; 
    for jj=1:51
        intBMsq(jj)=intBMsq(jj)+midptrule(BMsq(1:(jj-1)*100+1),1/10000)^2;
        %intBMsq(jj)=intBMsq(jj)+BMsq((jj-1)*100+1);
    end
end

mcpart=intBMsq/pathnum;
fname='case221';
save(fname,'mcpart');
toc

%% case212

tic
pathnum=10000;
intBMsq=zeros(51,1);
time=linspace(0,1/2,51)';
for pn=1:pathnum
    disp(pn);
    getpath=randommc(5001,212);
    %getpath=ones(size(getpath));
    %BMsq=getpath;   
    BMsq=getpath; 
    for jj=1:51
        intBMsq(jj)=intBMsq(jj)+midptrule(BMsq(1:(jj-1)*100+1),1/10000)^2;
        %intBMsq(jj)=intBMsq(jj)+BMsq((jj-1)*100+1);
    end
end

mcpart=intBMsq/pathnum;
fname='case212';
save(fname,'mcpart');
toc

%% case211
tic
pathnum=10000;
intBMsq=zeros(51,1);
time=linspace(0,1/2,51)';
for pn=1:pathnum
    disp(pn);
    getpath=randommc(5001,211);
    %getpath=ones(size(getpath));
    %BMsq=getpath;   
    BMsq=getpath; 
    for jj=1:51
        intBMsq(jj)=intBMsq(jj)+midptrule(BMsq(1:(jj-1)*100+1),1/10000)^2;
        %intBMsq(jj)=intBMsq(jj)+BMsq((jj-1)*100+1);
    end
end
toc
mcpart=intBMsq/pathnum;
fname='case211';
save(fname,'mcpart');